home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / leda / incl / window.bak < prev   
Encoding:
Text File  |  1991-11-15  |  8.9 KB  |  355 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  2.1.1                                                 11-15-1991
  4. +
  5. +
  6. +  window.h
  7. +
  8. +
  9. +  Copyright (c) 1991  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef WINDOW_H
  16. #define WINDOW_H
  17.  
  18. #include <LEDA/basic.h>
  19. #include <LEDA/plane.h>
  20.  
  21. declare(list,string)
  22.  
  23.  
  24. typedef double (*draw_func_ptr) (double);
  25. typedef void   (*redraw_func_ptr) ();
  26. typedef void   (*mouse_action_func_ptr) (double,double);
  27.  
  28. enum color  { white=0, 
  29.               black=1,  
  30.               red=2,    
  31.               green=3, 
  32.               blue=4,  
  33.               yellow=5, 
  34.               violet=6, 
  35.               orange=7
  36.              };
  37.  
  38. enum line_style   {solid, dashed, dotted};
  39. enum text_mode    {transparent, opaque};
  40. enum drawing_mode {src_mode, xor_mode};
  41.  
  42.  
  43. extern const int SCREEN_WIDTH;
  44. extern const int SCREEN_HEIGHT;
  45.  
  46. class window {
  47.  
  48. int state;
  49. list(string) mesg_list;
  50.  
  51. public:
  52.  
  53. window(float width, float height, float xpos, float ypos);
  54. window(float width = SCREEN_HEIGHT-20, float height = SCREEN_HEIGHT);
  55. ~window();
  56.  
  57. void init(double x0,double x1,double y0,int gmode = 0);
  58.  
  59. operator int() { return state; }
  60.  
  61.  
  62. void       set_redraw(redraw_func_ptr f);
  63. bool       set_font(char* s);
  64. void       set_grid_mode(int i);
  65. line_style set_line_style(line_style s) ;
  66. int        set_line_width(int w);
  67. drawing_mode set_mode(drawing_mode m);
  68. int        set_node_width(int w);
  69. text_mode  set_text_mode(text_mode m);
  70. void       set_frame_label(string s);
  71. void       set_flush(bool b);
  72.  
  73.  
  74. int          get_line_width();
  75. int          get_node_width();
  76. line_style   get_line_style();
  77. text_mode    get_text_mode();
  78. drawing_mode get_mode();
  79. int          mono();
  80.  
  81. double xmin();
  82. double xmax();
  83. double ymin();
  84. double ymax();
  85. double scale();
  86.  
  87. int xpix(double x);
  88. int ypix(double x);
  89.  
  90. double pixnum(int p);
  91.  
  92. // flushing window
  93.  
  94. void flush();
  95.  
  96.  
  97. // drawing segments
  98.  
  99. void draw_segment(double x1, double y1, double x2, double y2, color c = black );
  100. void draw_segment(point p, point q, color c = black );
  101. void draw_segment(segment s, color c = black );
  102.  
  103.  
  104. // drawing lines
  105.  
  106. void draw_line(double x1, double y1, double x2, double y2, color c = black );
  107. void draw_line(point p, point q, color c=black) ;
  108. void draw_line(line l, color c=black);
  109. void draw_hline(double y, color c = black );
  110. void draw_vline(double x, color c = black );
  111.  
  112.  
  113. // drawing arrows
  114.  
  115. void draw_arrow(double x1, double y1, double x2, double y2, color c = black );
  116. void draw_arrow(point p, point q, color c = black );
  117. void draw_arrow(segment s, color c = black );
  118.  
  119. // drawing edges
  120.  
  121. void draw_edge(double x1, double y1, double x2, double y2, color c = black );
  122. void draw_edge(point p, point q, color c = black );
  123. void draw_edge(segment s, color c = black );
  124.  
  125. void draw_edge_arrow(double x1, double y1, double x2, double y2, color c = black );
  126. void draw_edge_arrow(point p, point q, color c = black );
  127. void draw_edge_arrow(segment s, color c = black );
  128.  
  129.  
  130.  
  131. // drawing a single pixel
  132.  
  133. void draw_pix(double x, double y, color c = black );
  134. void draw_pix(point p, color c = black );
  135.  
  136.  
  137.  
  138. // drawing points
  139.  
  140. void draw_point(double x0,double y0,color c = black);
  141. void draw_point(point p,color c = black);
  142.  
  143.  
  144.  
  145. // drawing nodes
  146.  
  147. void draw_node(double x0,double y0,color c = black) ;
  148. void draw_node(point p, color c = black);
  149. void draw_filled_node(double x0,double y0,color c = black);
  150. void draw_filled_node(point p, color c = black);
  151. void draw_text_node(double x,double y,string s,color c = black);
  152. void draw_text_node(point p ,string s,color c = black);
  153. void draw_int_node(double x,double y,int i,color c = black);
  154. void draw_int_node(point p ,int i,color c = black);
  155.  
  156.  
  157. //circles
  158.  
  159. void draw_circle(double x,double y,double r,color c = black);
  160. void draw_circle(point p,double r,color c = black);
  161. void draw_circle(circle C,color c = black);
  162.  
  163. void draw_disc(double x,double y,double r,color c = black);
  164. void draw_disc(point p,double r,color c = black);
  165. void draw_disc(circle C,color c = black);
  166.  
  167. //ellipses
  168.  
  169. void draw_ellipse(double x,double y,double a, double b, color c = black);
  170. void draw_ellipse(point p, double a, double b, color c = black);
  171.  
  172.  
  173. //drawing polygons 
  174.  
  175. void draw_polygon(list(point) lp, color c = black );
  176. void draw_polygon(polygon P, color c = black );
  177. void draw_filled_polygon(list(point) lp, color c = black );
  178. void draw_filled_polygon(polygon P,color c = black );
  179.  
  180.  
  181. void draw_rectangle(double a, double  b, double c, double d, color col = black);
  182. void draw_filled_rectangle(double a, double  b, double c, double d, color col = black);
  183.  
  184.  
  185. // miscellaneous
  186. void copy_rect(double x1, double y1, double x2, double y2, double x, double y) ;
  187. void move_rect(double x1, double y1, double x2, double y2, double x, double y) ;
  188. void copy(double x1, double y1, double x2, double y2, int i=0) ;
  189. void cut(double x1, double y1, double x2, double y2, int i=0) ;
  190. void paste(int i, double x, double y);
  191. void paste(double x, double y);
  192. void clear_buf(int i=0);
  193.  
  194. void clear(color c = white);
  195. void show_window();
  196.  
  197.  
  198. // text
  199.  
  200. void draw_text(double x, double y, string s, color c = black);
  201. void draw_text(point p, string s, color c = black);
  202. void draw_ctext(double x, double y, string s, color c = black);
  203. void draw_ctext(point p, string s, color c = black);
  204.  
  205.  
  206.  
  207.  
  208. // drawing functions
  209.  
  210. void plot_xy(double x0, double x1, draw_func_ptr f, color c = black);
  211. void plot_yx(double y0, double y1, draw_func_ptr f, color c = black);
  212.  
  213.  
  214.  
  215. // mouse input
  216.  
  217. int read_mouse();
  218.  
  219. int read_mouse(real&, real&);
  220. int read_mouse(point&);
  221.  
  222. int read_mouse_seg(double, double, real&, real&);
  223. int read_mouse_seg(point, point&);
  224.  
  225. int read_mouse_rect(double, double, real&, real&);
  226. int read_mouse_rect(point, point&);
  227.  
  228. int read_mouse_circle(double, double, real&, real&);
  229. int read_mouse_circle(point, point&);
  230.  
  231. int read_mouse_action(mouse_action_func_ptr, real&, real&);
  232. int read_mouse_action(mouse_action_func_ptr, point&);
  233.  
  234.  
  235. // overloaded read and draw functions
  236.  
  237. window& read(point&);
  238. window& read(segment&);
  239. window& read(line&);
  240. window& read(polygon&);
  241. window& read(circle&);
  242.  
  243. window& draw(point p, color c = black);
  244. window& draw(segment s, color c = black);
  245. window& draw(line l, color c=black);
  246. window& draw(circle C,color c = black);
  247. window& draw(polygon P, color c = black );
  248.  
  249.  
  250. int  confirm(string s);
  251. void acknowledge(string s);
  252. void notice(string s);
  253.  
  254. int  read_panel(string, int, string*);
  255. int  read_vpanel(string, int, string*);
  256.  
  257. string  read_string(string,string,list(string)&);
  258. string  read_string(string,list(string)&);
  259. string  read_string(string);
  260.  
  261. real    read_real(string);
  262.  
  263. int     read_int(string);
  264.  
  265. //------------------------------------------------------------------------------
  266. // input operators
  267. //------------------------------------------------------------------------------
  268.  
  269. window& operator>>(point&);
  270. window& operator>>(segment&);
  271. window& operator>>(line&);
  272. window& operator>>(circle&);
  273. window& operator>>(polygon&);
  274.  
  275. //------------------------------------------------------------------------------
  276. // output
  277. //------------------------------------------------------------------------------
  278.  
  279. window& operator<<(point p)   { draw(p); return *this; }
  280. window& operator<<(segment s) { draw(s); return *this; }
  281. window& operator<<(line l)    { draw(l); return *this; }
  282. window& operator<<(circle C)  { draw(C); return *this; }
  283. window& operator<<(polygon P) { draw(P); return *this; }
  284.  
  285.  
  286. void     message(string);
  287. void     del_message();
  288.  
  289. void     add_message(string);
  290. void     clear_messages();
  291. void     show_message();
  292.  
  293. }; // end of class window
  294.   
  295.  
  296.  
  297. #ifndef __TURBOC__
  298.  
  299. //------------------------------------------------------------------------------
  300. //   PANELS
  301. //------------------------------------------------------------------------------
  302.  
  303. struct panel {
  304.  
  305. void* panel_ptr;
  306.  
  307.  panel();
  308.  panel(string s);
  309. ~panel();
  310.  
  311.  
  312. void label(string s);
  313. void text_item(string s);
  314.  
  315. void string_item(string s, string& x);
  316. void string_item(string label,string& x,list(string)& L);
  317.  
  318. void choice_item(string header,int& x,int n,string* L);
  319. void choice_item(string header,int& x,list(string)& L);
  320. void choice_item(string header,int& x,string,string);
  321. void choice_item(string header,int& x,string,string,string);
  322. void choice_item(string header,int& x,string,string,string,string);
  323. void choice_item(string header,int& x,string,string,string,string,string);
  324.  
  325. void int_item(string s,int& x);
  326. void int_item(string s,int& x, int l, int h, int step);
  327. void int_item(string s,int& x, int l, int h);
  328.  
  329. void bool_item(string s, int& x);
  330. void real_item(string s, real& x);
  331. void double_item(string s, double& x);
  332.  
  333. void color_item(string s, color& x);
  334.  
  335. void button(string s);
  336. void button(int i,int l=1);
  337.  
  338. void new_button_line();
  339. void new_button_line(int,string*);
  340. void new_button_line(list(string)&);
  341.  
  342.  
  343. int  open();
  344.  
  345. int  open(int n, string* buttons) { new_button_line(n,buttons); return open();}
  346.  
  347. int  open(list(string) buttons)   { new_button_line(buttons); return open(); }
  348.  
  349. };
  350.  
  351. #endif
  352.  
  353. #endif
  354.